#include "vector.hpp"
#include "matrix22.hpp"

namespace fixedpoint {
  fixpoint vec2d::abs() const
  {
    return sqrt(dot(*this));
  }

  fixpoint vec2d::angle() const
  {
    return 0; //Implement me! (write fixed-point atan2() first)
  }

  vec2d vec2d::unit() const
  {
    fixpoint invabs = invsqrt(dot(*this));
    return operator*(invabs);
  }

  vec2d& vec2d::normalize() {
    fixpoint invabs = invsqrt(dot(*this));
    return operator*=(invabs);
  }

  mat22 vec2d::outerprod(const vec2d& a) const
  {
    return mat22(x*a.x, y*a.x,
		 x*a.y, y*a.y);
  }
}
